import  pandas as pd
import  json
import tos
import  time
import uuid
import mysql.connector
import logging
from bytehouse_driver import Client
import logging
import numpy as np
import json
# Access key 和 Secret key 可在用户火山引擎账号中查找
ak = "AKLTMmFmMzVmNmY5ZDEyNDNmNWEyZTU2MDM3Y2EzMDJlZTk"
sk = "WVdNeFpXRXdNekV4Tm1ZME5EZGxPRGc0TUdFNE1HWXdNV1ZqTkdNNU9HRQ=="
# your endpoint 和 your region 填写Bucket 所在区域对应的Endpoint。# 以华北2(北京)为例，your endpoint 填写 tos-cn-beijing.volces.com，your region 填写 cn-beijing。
endpoint = "tos-cn-beijing.ivolces.com"
region = "cn-beijing"

# 文件上传：
def get_dict_list(dict,dict_list):
    start_time_str=dict['scid_start_time_str']
    hour = start_time_str[11:13]
    dict_list.append(dict['vehicle_id'])
    dict_list.append(dict['start_time_str'])
    dict_list.append(dict['scid'])
    dict_list.append(dict['path'])
    dict_list.append(dict['level1'])
    dict_list.append(dict['level2'])
    dict_list.append(dict['level3'])
    dict_list.append(dict['day'])
    dict_list.append(dict['month'])
    dict_list.append(dict["scid_start_time_str"])
    dict_list.append(dict['icu2_odometer'])
    dict_list.append(dict['idb3_vehiclespd'])
    dict_list.append(dict['acu2_longaccsensorvalue'])
    dict_list.append(dict['acu2_lataccsensorvalue'])
    dict_list.append(dict['acu2_vehicledynyawrate'])
    dict_list.append(dict['eps1_steeranglespd'])
    dict_list.append(dict['eps1_torsionbartorque'])
    dict_list.append(dict['cs1_gearpositionreqst'])
    dict_list.append(dict['uid'])
    dict_list.append(dict['day'])
    dict_list.append(hour)

    return dict_list

def get_scid_time(df_acc_100ms):
    df_acc_100ms_list= df_acc_100ms[
        ['start_time_str','path','nsecs','VLCCDHypotheses_Hypothesis_0_fTTC','VLCCDHypotheses_Hypothesis_0_fDistX','VLCCDHypotheses_Hypothesis_0_fDistY',
         'VLCCDHypotheses_Hypothesis_0_fVrelX','VLCCDHypotheses_Hypothesis_0_fVrelY','IDB3_VehicleSpd','ACU2_LongAccSensorValue','ACU2_LatAccSensorValue',
         'ACU2_VehicleDynYawRate','IDB1_BrakePedalApplied','EPS1_SteerAngleSpd','CamLaneData_CourseInfo_1_CourseInfoSegNear_f_C0',
         'ADCS12_longitudCtrlSysInfo','ADCS12_longitudDisableInfo','ICU2_Odometer','EPS1_TorsionBarTorque','CS1_GearPositionReqSt'
         ]].values.tolist()


    found_index = -9999
    start_time_str=""
    found_ICU2_Odometer=0.0
    found_IDB3_VehicleSpd=0.0
    found_ACU2_LongAccSensorValue=0.0
    found_ACU2_LatAccSensorValue=0.0
    found_ACU2_VehicleDynYawRate=0.0
    found_EPS1_SteerAngleSpd=0.0
    found_EPS1_TorsionBarTorque=0.0
    found_CS1_GearPositionReqSt=0
    # 遍历列表
    for index, element in enumerate(df_acc_100ms_list):
        start_time_str=element[0]
        path = element[1]
        nsecs = element[2]
        ADCS12_longitudCtrlSysInfo = element[15]
        ADCS12_longitudDisableInfo = element[16]
        ICU2_Odometer= element[17]
        IDB3_VehicleSpd=element[8]
        ACU2_LongAccSensorValue = element[9]
        ACU2_LatAccSensorValue=element[10]
        ACU2_VehicleDynYawRate=element[11]
        EPS1_SteerAngleSpd=element[13]
        EPS1_TorsionBarTorque = element[18]
        CS1_GearPositionReqSt = element[19]
        if ADCS12_longitudCtrlSysInfo==1 or ADCS12_longitudDisableInfo!= 0:
            found_index = index
            found_ICU2_Odometer=ICU2_Odometer
            found_IDB3_VehicleSpd=IDB3_VehicleSpd
            found_ACU2_LongAccSensorValue=ACU2_LongAccSensorValue
            found_ACU2_LatAccSensorValue=ACU2_LatAccSensorValue
            found_ACU2_VehicleDynYawRate=ACU2_VehicleDynYawRate
            found_EPS1_SteerAngleSpd=EPS1_SteerAngleSpd
            found_EPS1_TorsionBarTorque=EPS1_TorsionBarTorque
            found_CS1_GearPositionReqSt=CS1_GearPositionReqSt


            break  # 找到第一个符合条件的元素就跳出循环
    logging.info("found_index: "+str(found_index))
    dict_scid={}
    dict_scid["scid_start_time_str"]=start_time_str
    dict_scid["ICU2_Odometer"] = found_ICU2_Odometer
    dict_scid["IDB3_VehicleSpd"] = found_IDB3_VehicleSpd
    dict_scid["ACU2_LongAccSensorValue"] = found_ACU2_LongAccSensorValue
    dict_scid["ACU2_LatAccSensorValue"] = found_ACU2_LatAccSensorValue
    dict_scid["ACU2_VehicleDynYawRate"] = found_ACU2_VehicleDynYawRate
    dict_scid["EPS1_SteerAngleSpd"] = found_EPS1_SteerAngleSpd
    dict_scid["EPS1_TorsionBarTorque"] = found_EPS1_TorsionBarTorque
    dict_scid["CS1_GearPositionReqSt"] = found_CS1_GearPositionReqSt
    return dict_scid
def add_to_bytehouse(dict):
    HOST="bytehouse-cn-beijing.volces.com"
    PORT="19000"
    API_KEY="q2p9nLj7tq:TKOCmgrMKp"
    # 配置数据库连接信息
    DATABASE="dwd"
    client = Client.from_url('bytehouse://{}:{}/?user=bytehouse&password={}&database={}&secure=true'.format(HOST, PORT, API_KEY, DATABASE))
    client.execute("INSERT INTO dwd.dwd_trigger_sc_ep40_tda4_v2 VALUES", [
        [dict['vehicle_id'], dict['start_time_str'], dict['scid'], dict['path'], dict['level1'], dict['level2'],
         dict['level3'], dict['day'], dict['month'],dict["scid_start_time_str"], dict['icu2_odometer'], dict['idb3_vehiclespd'],
         dict['acu2_longaccsensorvalue'], dict['acu2_lataccsensorvalue'], dict['acu2_vehicledynyawrate'],
         dict['eps1_steeranglespd'],dict['eps1_torsionbartorque'], dict['cs1_gearpositionreqst'], dict['uid'],dict['day']]])
def get_can_out_20ms_list(df_can_20ms_acc_active_list,nsecs):
    # 找到最接近目标值的行数据
    closest_data = min(df_can_20ms_acc_active_list, key=lambda x: abs(x[2] - nsecs))

    # 打印结果
    return  closest_data
def uploadjson(bucket_name,object_key,jsonstr):
    try:
        client = tos.TosClientV2(ak, sk, endpoint, region)
        # 若在上传对象时设置文件存储类型（x-tos-storage-class）和访问权限 (x-tos-acl), 请在 put_object中设置相关参数
        # 用户在上传对象时，可以自定义元数据，以便对对象进行自定义管理
        # result = client.put_object(bucket_name, object_key, content=content, acl=tos.ACLType.ACL_Private, storage_class=tos.StorageClassType.Storage_Class_Standard, meta={'name': '张三', 'age': '20'})
        result = client.put_object(bucket_name, object_key, content=jsonstr)
        # HTTP状态码
        print('http status code:{}'.format(result.status_code))
        # 请求ID。请求ID是本次请求的唯一标识，建议在日志中添加此参数
        print('request_id: {}'.format(result.request_id))
        # hash_crc64_ecma 表示该对象的64位CRC值, 可用于验证上传对象的完整性
        print('crc64: {}'.format(result.hash_crc64_ecma))
    except tos.exceptions.TosClientError as e:
        # 操作失败，捕获客户端异常，一般情况为非法请求参数或网络异常
        print('fail with client error, message:{}, cause: {}'.format(e.message, e.cause))
    except tos.exceptions.TosServerError as e:
        # 操作失败，捕获服务端异常，可从返回信息中获取详细错误信息
        print('fail with server error, code: {}'.format(e.code))
        # request id 可定位具体问题，强烈建议日志中保存
        print('error with request id: {}'.format(e.request_id))
        print('error with message: {}'.format(e.message))
        print('error with http code: {}'.format(e.status_code))
        print('error with ec: {}'.format(e.ec))
        print('error with request url: {}'.format(e.request_url))
    except Exception as e:
        print('fail with unknown error: {}'.format(e))
def get_timestamp(time_string):
    # 转换为时间元组
    time_tuple = time.strptime(time_string, "%Y-%m-%d %H:%M:%S")
    # 转换为时间戳
    timestamp = str(int(time.mktime(time_tuple)*1000))
    return timestamp
def add_to_mysql(json_str):
    # 配置数据库连接信息
    db_config = {
        'host': 'mysql-d8beb8b0655b-public.rds.volces.com',
        'user': 'user01',
        'password': 'password123!#',
        'database': 'bi_test'
    }
    # 创建数据库连接
    conn = mysql.connector.connect(**db_config)
    cursor = conn.cursor()

    # 假设你有一个名为 'your_table' 的表，包含 'column1', 'column2', 'column3' 等字段
    table_name = 'trigger_sc_ep40_tda4'

    # 假设你有一个数据字典，包含要插入的数据
    data_to_insert = json.loads(json_str)

    # 构建 SQL 插入语句
    columns = ', '.join(data_to_insert.keys())
    values = ', '.join(['%s'] * len(data_to_insert))
    sql_insert = f"replace into {table_name} ({columns}) VALUES ({values})"

    # 执行插入操作
    cursor.execute(sql_insert, list(data_to_insert.values()))

    # 提交更改
    conn.commit()
def get_model_feature(found_index,df_list,start_time_str):
    if found_index >= 11:
        VLCCDHypotheses_Hypothesis_0_fTTC_last_list = df_list[found_index - 11:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fTTC_last= [row[3] for row in VLCCDHypotheses_Hypothesis_0_fTTC_last_list]
        VLCCDHypotheses_Hypothesis_0_fTTC_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fTTC_last)
        AEB_Target_Estimated_Time_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fTTC_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fTTC_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fTTC_next =[row[3] for row in VLCCDHypotheses_Hypothesis_0_fTTC_next_list]
        VLCCDHypotheses_Hypothesis_0_fTTC_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fTTC_next)
        AEB_Target_Estimated_Time_post = np.mean(VLCCDHypotheses_Hypothesis_0_fTTC_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fDistX_last_list = df_list[found_index - 11:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fDistX_last= [row[4] for row in VLCCDHypotheses_Hypothesis_0_fDistX_last_list]
        VLCCDHypotheses_Hypothesis_0_fDistX_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistX_last)
        AEB_Target_Longitudinal_Distance_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fDistX_last_nnp)


        VLCCDHypotheses_Hypothesis_0_fDistX_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fDistX_next= [row[4] for row in VLCCDHypotheses_Hypothesis_0_fDistX_next_list]
        VLCCDHypotheses_Hypothesis_0_fDistX_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistX_next)
        AEB_Target_Longitudinal_Distance_post = np.mean(VLCCDHypotheses_Hypothesis_0_fDistX_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fDistY_last_list = df_list[found_index - 11:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fDistY_last = [row[5] for row in VLCCDHypotheses_Hypothesis_0_fDistY_last_list]
        VLCCDHypotheses_Hypothesis_0_fDistY_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistY_last)
        AEB_Target_Cross_Range_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fDistY_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fDistY_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fDistY_next = [row[5] for row in VLCCDHypotheses_Hypothesis_0_fDistY_next_list]
        VLCCDHypotheses_Hypothesis_0_fDistY_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistY_next)
        AEB_Target_Cross_Range_post = np.mean(VLCCDHypotheses_Hypothesis_0_fDistY_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelX_last_list = df_list[found_index - 11:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fVrelX_last = [row[6] for row in VLCCDHypotheses_Hypothesis_0_fVrelX_last_list]
        VLCCDHypotheses_Hypothesis_0_fVrelX_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelX_last)
        AEB_Target_Longitudinal_Velocity_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelX_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelX_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fVrelX_next = [row[6] for row in VLCCDHypotheses_Hypothesis_0_fVrelX_next_list]
        VLCCDHypotheses_Hypothesis_0_fVrelX_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelX_next)
        AEB_Target_Longitudinal_Velocity_post = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelX_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelY_last_list = df_list[found_index - 11:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fVrelY_last = [row[7] for row in VLCCDHypotheses_Hypothesis_0_fVrelY_last_list]
        VLCCDHypotheses_Hypothesis_0_fVrelY_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelY_last)
        AEB_Target_Lateral_Velocity_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelY_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelY_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fVrelY_next = [row[7] for row in VLCCDHypotheses_Hypothesis_0_fVrelY_next_list]
        VLCCDHypotheses_Hypothesis_0_fVrelY_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelY_next)
        AEB_Target_Lateral_Velocity_post = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelY_next_nnp)

        IDB3_VehicleSpd_last_list = df_list[found_index - 11:found_index - 1]
        IDB3_VehicleSpd_last = [row[8] for row in IDB3_VehicleSpd_last_list]
        IDB3_VehicleSpd_last_nnp = np.array(IDB3_VehicleSpd_last)
        IDB3_VehicleSpd_pre = np.mean(IDB3_VehicleSpd_last_nnp)

        IDB3_VehicleSpd_last_next_list = df_list[found_index + 1:found_index + 11]
        IDB3_VehicleSpd_last_next = [row[8] for row in IDB3_VehicleSpd_last_next_list]
        IDB3_VehicleSpd_last_next_nnp = np.array(IDB3_VehicleSpd_last_next)
        IDB3_VehicleSpd_post = np.mean(IDB3_VehicleSpd_last_next_nnp)

        ACU2_LongAccSensorValue_last_list = df_list[found_index - 11:found_index - 1]
        ACU2_LongAccSensorValue_last = [row[9] for row in ACU2_LongAccSensorValue_last_list]
        ACU2_LongAccSensorValue_last_nnp = np.array(ACU2_LongAccSensorValue_last)
        ACU2_LongAccSensorValue_pre = np.mean(ACU2_LongAccSensorValue_last_nnp)

        ACU2_LongAccSensorValue_next_list = df_list[found_index + 1:found_index + 11]
        ACU2_LongAccSensorValue_next = [row[9] for row in ACU2_LongAccSensorValue_next_list]
        ACU2_LongAccSensorValue_next_nnp = np.array(ACU2_LongAccSensorValue_next)
        ACU2_LongAccSensorValue_post = np.mean(ACU2_LongAccSensorValue_next_nnp)

        ACU2_LatAccSensorValue_last_list = df_list[found_index - 11:found_index - 1]
        ACU2_LatAccSensorValue_last = [row[10] for row in ACU2_LatAccSensorValue_last_list]
        ACU2_LatAccSensorValue_last_nnp = np.array(ACU2_LatAccSensorValue_last)
        ACU2_LatAccSensorValue_pre = np.mean(ACU2_LatAccSensorValue_last_nnp)

        ACU2_LatAccSensorValue_next_list = df_list[found_index + 1:found_index + 11]
        ACU2_LatAccSensorValue_next = [row[10] for row in ACU2_LatAccSensorValue_next_list]
        ACU2_LatAccSensorValue_next_nnp = np.array(ACU2_LatAccSensorValue_next)
        ACU2_LatAccSensorValue_post = np.mean(ACU2_LatAccSensorValue_next_nnp)

        ACU2_VehicleDynYawRate_last_list = df_list[found_index - 11:found_index - 1]
        ACU2_VehicleDynYawRate_last = [row[11] for row in ACU2_VehicleDynYawRate_last_list]
        ACU2_VehicleDynYawRate_last_nnp = np.array(ACU2_VehicleDynYawRate_last)
        ACU2_VehicleDynYawRate_pre = np.mean(ACU2_VehicleDynYawRate_last_nnp)

        ACU2_VehicleDynYawRate_next_list = df_list[found_index + 1:found_index + 11]
        ACU2_VehicleDynYawRate_next = [row[11] for row in ACU2_VehicleDynYawRate_next_list]
        ACU2_VehicleDynYawRate_next_nnp = np.array(ACU2_VehicleDynYawRate_next)
        ACU2_VehicleDynYawRate_post = np.mean(ACU2_VehicleDynYawRate_next_nnp)

        AEB_Target_Estimated_Time_diff = AEB_Target_Estimated_Time_post - AEB_Target_Estimated_Time_pre
        AEB_Target_Longitudinal_Distance_diff = AEB_Target_Longitudinal_Distance_post - AEB_Target_Longitudinal_Distance_pre
        AEB_Target_Cross_Range_diff = AEB_Target_Cross_Range_post - AEB_Target_Cross_Range_pre
        AEB_Target_Longitudinal_Velocity_diff = AEB_Target_Longitudinal_Velocity_post - AEB_Target_Longitudinal_Velocity_pre
        AEB_Target_Lateral_Velocity_diff = AEB_Target_Lateral_Velocity_post - AEB_Target_Lateral_Velocity_pre
        IDB3_VehicleSpd_diff = IDB3_VehicleSpd_post - IDB3_VehicleSpd_pre
        ACU2_LongAccSensorValue_diff = ACU2_LongAccSensorValue_post - ACU2_LongAccSensorValue_pre
        ACU2_LatAccSensorValue_diff = ACU2_LatAccSensorValue_post - ACU2_LatAccSensorValue_pre
        ACU2_VehicleDynYawRate_diff = ACU2_VehicleDynYawRate_post - ACU2_VehicleDynYawRate_pre

        IDB1_BrakePedalApplied_next_list = df_list[found_index + 1:found_index + 11]
        IDB1_BrakePedalApplied_next = [row[12] for row in IDB1_BrakePedalApplied_next_list]
        IDB1_BrakePedalApplied_next_nnp = np.array(IDB1_BrakePedalApplied_next)
        IDB1_BrakePedalApplied = np.mean(IDB1_BrakePedalApplied_next_nnp)

        EPS1_SteerAngleSpd_next_list = df_list[found_index + 1:found_index + 11]
        EPS1_SteerAngleSpd_next = [row[13] for row in EPS1_SteerAngleSpd_next_list]
        EPS1_SteerAngleSpd_next_nnp = np.array(EPS1_SteerAngleSpd_next)
        EPS1_SteerAngleSpd = np.max(EPS1_SteerAngleSpd_next_nnp)

        lane_curve_list = []
        if found_index - 31 >= 0:
            lane_curve_list_fat = df_list[found_index - 31:found_index - 1]
            lane_curve_list = [row[14] for row in lane_curve_list_fat]
        else:
            lane_curve_list_fat = df_list[0:found_index - 1]
            lane_curve_list = [row[14] for row in lane_curve_list_fat]
        lane_curve = max(map(abs, lane_curve_list))
        logging.info("lane_curve: "+str(lane_curve))

        hour = start_time_str[11:13]
        data = {'AEB_Target_Estimated_Time_pre': [AEB_Target_Estimated_Time_pre],
                'AEB_Target_Estimated_Time_post': [AEB_Target_Estimated_Time_post],
                'AEB_Target_Longitudinal_Distance_pre': [AEB_Target_Longitudinal_Distance_pre],
                'AEB_Target_Longitudinal_Distance_post': [AEB_Target_Longitudinal_Distance_post],
                'AEB_Target_Cross_Range_pre': [AEB_Target_Cross_Range_pre],
                'AEB_Target_Cross_Range_post': [AEB_Target_Cross_Range_post],
                'AEB_Target_Longitudinal_Velocity_pre': [AEB_Target_Longitudinal_Velocity_pre],
                'AEB_Target_Longitudinal_Velocity_post': [AEB_Target_Longitudinal_Velocity_post],
                'AEB_Target_Lateral_Velocity_pre': [AEB_Target_Lateral_Velocity_pre],
                'AEB_Target_Lateral_Velocity_post': [AEB_Target_Lateral_Velocity_post],
                'IDB3_VehicleSpd_pre': [IDB3_VehicleSpd_pre],
                'IDB3_VehicleSpd_post': [IDB3_VehicleSpd_post],
                'ACU2_LongAccSensorValue_pre': [ACU2_LongAccSensorValue_pre],
                'ACU2_LongAccSensorValue_post': [ACU2_LongAccSensorValue_post],
                'ACU2_LatAccSensorValue_pre': [ACU2_LatAccSensorValue_pre],
                'ACU2_LatAccSensorValue_post': [ACU2_LatAccSensorValue_post],
                'ACU2_VehicleDynYawRate_pre': [ACU2_VehicleDynYawRate_pre],
                'ACU2_VehicleDynYawRate_post': [ACU2_VehicleDynYawRate_post],
                'AEB_Target_Estimated_Time_diff': [AEB_Target_Estimated_Time_diff],
                'AEB_Target_Longitudinal_Distance_diff': [AEB_Target_Longitudinal_Distance_diff],
                'AEB_Target_Cross_Range_diff': [AEB_Target_Cross_Range_diff],
                'AEB_Target_Longitudinal_Velocity_diff': [AEB_Target_Longitudinal_Velocity_diff],
                'AEB_Target_Lateral_Velocity_diff': [AEB_Target_Lateral_Velocity_diff],
                'IDB3_VehicleSpd_diff': [IDB3_VehicleSpd_diff],
                'ACU2_LongAccSensorValue_diff': [ACU2_LongAccSensorValue_diff],
                'ACU2_LatAccSensorValue_diff': [ACU2_LatAccSensorValue_diff],
                'ACU2_VehicleDynYawRate_diff': [ACU2_VehicleDynYawRate_diff],
                'IDB1_BrakePedalApplied': [IDB1_BrakePedalApplied],
                'EPS1_SteerAngleSpd': [EPS1_SteerAngleSpd],
                'lane_curve': [lane_curve],
                'hour': [hour]
                }
        df = pd.DataFrame(data)
    else:
        VLCCDHypotheses_Hypothesis_0_fTTC_last_list = df_list[0:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fTTC_last= [row[3] for row in VLCCDHypotheses_Hypothesis_0_fTTC_last_list]
        VLCCDHypotheses_Hypothesis_0_fTTC_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fTTC_last)
        AEB_Target_Estimated_Time_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fTTC_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fTTC_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fTTC_next =[row[3] for row in VLCCDHypotheses_Hypothesis_0_fTTC_next_list]
        VLCCDHypotheses_Hypothesis_0_fTTC_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fTTC_next)
        AEB_Target_Estimated_Time_post = np.mean(VLCCDHypotheses_Hypothesis_0_fTTC_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fDistX_last_list = df_list[0:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fDistX_last= [row[4] for row in VLCCDHypotheses_Hypothesis_0_fDistX_last_list]
        VLCCDHypotheses_Hypothesis_0_fDistX_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistX_last)
        AEB_Target_Longitudinal_Distance_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fDistX_last_nnp)


        VLCCDHypotheses_Hypothesis_0_fDistX_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fDistX_next= [row[4] for row in VLCCDHypotheses_Hypothesis_0_fDistX_next_list]
        VLCCDHypotheses_Hypothesis_0_fDistX_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistX_next)
        AEB_Target_Longitudinal_Distance_post = np.mean(VLCCDHypotheses_Hypothesis_0_fDistX_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fDistY_last_list = df_list[0:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fDistY_last = [row[5] for row in VLCCDHypotheses_Hypothesis_0_fDistY_last_list]
        VLCCDHypotheses_Hypothesis_0_fDistY_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistY_last)
        AEB_Target_Cross_Range_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fDistY_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fDistY_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fDistY_next = [row[5] for row in VLCCDHypotheses_Hypothesis_0_fDistY_next_list]
        VLCCDHypotheses_Hypothesis_0_fDistY_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fDistY_next)
        AEB_Target_Cross_Range_post = np.mean(VLCCDHypotheses_Hypothesis_0_fDistY_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelX_last_list = df_list[0:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fVrelX_last = [row[6] for row in VLCCDHypotheses_Hypothesis_0_fVrelX_last_list]
        VLCCDHypotheses_Hypothesis_0_fVrelX_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelX_last)
        AEB_Target_Longitudinal_Velocity_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelX_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelX_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fVrelX_next = [row[6] for row in VLCCDHypotheses_Hypothesis_0_fVrelX_next_list]
        VLCCDHypotheses_Hypothesis_0_fVrelX_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelX_next)
        AEB_Target_Longitudinal_Velocity_post = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelX_next_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelY_last_list = df_list[0:found_index - 1]
        VLCCDHypotheses_Hypothesis_0_fVrelY_last = [row[7] for row in VLCCDHypotheses_Hypothesis_0_fVrelY_last_list]
        VLCCDHypotheses_Hypothesis_0_fVrelY_last_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelY_last)
        AEB_Target_Lateral_Velocity_pre = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelY_last_nnp)

        VLCCDHypotheses_Hypothesis_0_fVrelY_next_list = df_list[found_index + 1:found_index + 11]
        VLCCDHypotheses_Hypothesis_0_fVrelY_next = [row[7] for row in VLCCDHypotheses_Hypothesis_0_fVrelY_next_list]
        VLCCDHypotheses_Hypothesis_0_fVrelY_next_nnp = np.array(VLCCDHypotheses_Hypothesis_0_fVrelY_next)
        AEB_Target_Lateral_Velocity_post = np.mean(VLCCDHypotheses_Hypothesis_0_fVrelY_next_nnp)

        IDB3_VehicleSpd_last_list = df_list[0:found_index - 1]
        IDB3_VehicleSpd_last = [row[8] for row in IDB3_VehicleSpd_last_list]
        IDB3_VehicleSpd_last_nnp = np.array(IDB3_VehicleSpd_last)
        IDB3_VehicleSpd_pre = np.mean(IDB3_VehicleSpd_last_nnp)

        IDB3_VehicleSpd_last_next_list = df_list[found_index + 1:found_index + 11]
        IDB3_VehicleSpd_last_next = [row[8] for row in IDB3_VehicleSpd_last_next_list]
        IDB3_VehicleSpd_last_next_nnp = np.array(IDB3_VehicleSpd_last_next)
        IDB3_VehicleSpd_post = np.mean(IDB3_VehicleSpd_last_next_nnp)

        ACU2_LongAccSensorValue_last_list = df_list[0:found_index - 1]
        ACU2_LongAccSensorValue_last = [row[9] for row in ACU2_LongAccSensorValue_last_list]
        ACU2_LongAccSensorValue_last_nnp = np.array(ACU2_LongAccSensorValue_last)
        ACU2_LongAccSensorValue_pre = np.mean(ACU2_LongAccSensorValue_last_nnp)

        ACU2_LongAccSensorValue_next_list = df_list[found_index + 1:found_index + 11]
        ACU2_LongAccSensorValue_next = [row[9] for row in ACU2_LongAccSensorValue_next_list]
        ACU2_LongAccSensorValue_next_nnp = np.array(ACU2_LongAccSensorValue_next)
        ACU2_LongAccSensorValue_post = np.mean(ACU2_LongAccSensorValue_next_nnp)

        ACU2_LatAccSensorValue_last_list = df_list[0:found_index - 1]
        ACU2_LatAccSensorValue_last = [row[10] for row in ACU2_LatAccSensorValue_last_list]
        ACU2_LatAccSensorValue_last_nnp = np.array(ACU2_LatAccSensorValue_last)
        ACU2_LatAccSensorValue_pre = np.mean(ACU2_LatAccSensorValue_last_nnp)

        ACU2_LatAccSensorValue_next_list = df_list[found_index + 1:found_index + 11]
        ACU2_LatAccSensorValue_next = [row[10] for row in ACU2_LatAccSensorValue_next_list]
        ACU2_LatAccSensorValue_next_nnp = np.array(ACU2_LatAccSensorValue_next)
        ACU2_LatAccSensorValue_post = np.mean(ACU2_LatAccSensorValue_next_nnp)

        ACU2_VehicleDynYawRate_last_list = df_list[0:found_index - 1]
        ACU2_VehicleDynYawRate_last = [row[11] for row in ACU2_VehicleDynYawRate_last_list]
        ACU2_VehicleDynYawRate_last_nnp = np.array(ACU2_VehicleDynYawRate_last)
        ACU2_VehicleDynYawRate_pre = np.mean(ACU2_VehicleDynYawRate_last_nnp)

        ACU2_VehicleDynYawRate_next_list = df_list[found_index + 1:found_index + 11]
        ACU2_VehicleDynYawRate_next = [row[11] for row in ACU2_VehicleDynYawRate_next_list]
        ACU2_VehicleDynYawRate_next_nnp = np.array(ACU2_VehicleDynYawRate_next)
        ACU2_VehicleDynYawRate_post = np.mean(ACU2_VehicleDynYawRate_next_nnp)

        AEB_Target_Estimated_Time_diff = AEB_Target_Estimated_Time_post - AEB_Target_Estimated_Time_pre
        AEB_Target_Longitudinal_Distance_diff = AEB_Target_Longitudinal_Distance_post - AEB_Target_Longitudinal_Distance_pre
        AEB_Target_Cross_Range_diff = AEB_Target_Cross_Range_post - AEB_Target_Cross_Range_pre
        AEB_Target_Longitudinal_Velocity_diff = AEB_Target_Longitudinal_Velocity_post - AEB_Target_Longitudinal_Velocity_pre
        AEB_Target_Lateral_Velocity_diff = AEB_Target_Lateral_Velocity_post - AEB_Target_Lateral_Velocity_pre
        IDB3_VehicleSpd_diff = IDB3_VehicleSpd_post - IDB3_VehicleSpd_pre
        ACU2_LongAccSensorValue_diff = ACU2_LongAccSensorValue_post - ACU2_LongAccSensorValue_pre
        ACU2_LatAccSensorValue_diff = ACU2_LatAccSensorValue_post - ACU2_LatAccSensorValue_pre
        ACU2_VehicleDynYawRate_diff = ACU2_VehicleDynYawRate_post - ACU2_VehicleDynYawRate_pre

        IDB1_BrakePedalApplied_next_list = df_list[found_index + 1:found_index + 11]
        IDB1_BrakePedalApplied_next = [row[12] for row in IDB1_BrakePedalApplied_next_list]
        IDB1_BrakePedalApplied_next_nnp = np.array(IDB1_BrakePedalApplied_next)
        IDB1_BrakePedalApplied = np.mean(IDB1_BrakePedalApplied_next_nnp)

        EPS1_SteerAngleSpd_next_list = df_list[found_index + 1:found_index + 11]
        EPS1_SteerAngleSpd_next = [row[13] for row in EPS1_SteerAngleSpd_next_list]
        EPS1_SteerAngleSpd_next_nnp = np.array(EPS1_SteerAngleSpd_next)
        EPS1_SteerAngleSpd = np.max(EPS1_SteerAngleSpd_next_nnp)

        lane_curve_list = []
        if found_index - 31 >= 0:
            lane_curve_list_fat = df_list[found_index - 31:found_index - 1]
            lane_curve_list = [row[14] for row in lane_curve_list_fat]
        else:
            lane_curve_list_fat = df_list[0:found_index - 1]
            lane_curve_list = [row[14] for row in lane_curve_list_fat]
        lane_curve = max(map(abs, lane_curve_list))
        logging.info("lane_curve: "+str(lane_curve))

        hour = start_time_str[11:13]
        data = {'AEB_Target_Estimated_Time_pre': [AEB_Target_Estimated_Time_pre],
                'AEB_Target_Estimated_Time_post': [AEB_Target_Estimated_Time_post],
                'AEB_Target_Longitudinal_Distance_pre': [AEB_Target_Longitudinal_Distance_pre],
                'AEB_Target_Longitudinal_Distance_post': [AEB_Target_Longitudinal_Distance_post],
                'AEB_Target_Cross_Range_pre': [AEB_Target_Cross_Range_pre],
                'AEB_Target_Cross_Range_post': [AEB_Target_Cross_Range_post],
                'AEB_Target_Longitudinal_Velocity_pre': [AEB_Target_Longitudinal_Velocity_pre],
                'AEB_Target_Longitudinal_Velocity_post': [AEB_Target_Longitudinal_Velocity_post],
                'AEB_Target_Lateral_Velocity_pre': [AEB_Target_Lateral_Velocity_pre],
                'AEB_Target_Lateral_Velocity_post': [AEB_Target_Lateral_Velocity_post],
                'IDB3_VehicleSpd_pre': [IDB3_VehicleSpd_pre],
                'IDB3_VehicleSpd_post': [IDB3_VehicleSpd_post],
                'ACU2_LongAccSensorValue_pre': [ACU2_LongAccSensorValue_pre],
                'ACU2_LongAccSensorValue_post': [ACU2_LongAccSensorValue_post],
                'ACU2_LatAccSensorValue_pre': [ACU2_LatAccSensorValue_pre],
                'ACU2_LatAccSensorValue_post': [ACU2_LatAccSensorValue_post],
                'ACU2_VehicleDynYawRate_pre': [ACU2_VehicleDynYawRate_pre],
                'ACU2_VehicleDynYawRate_post': [ACU2_VehicleDynYawRate_post],
                'AEB_Target_Estimated_Time_diff': [AEB_Target_Estimated_Time_diff],
                'AEB_Target_Longitudinal_Distance_diff': [AEB_Target_Longitudinal_Distance_diff],
                'AEB_Target_Cross_Range_diff': [AEB_Target_Cross_Range_diff],
                'AEB_Target_Longitudinal_Velocity_diff': [AEB_Target_Longitudinal_Velocity_diff],
                'AEB_Target_Lateral_Velocity_diff': [AEB_Target_Lateral_Velocity_diff],
                'IDB3_VehicleSpd_diff': [IDB3_VehicleSpd_diff],
                'ACU2_LongAccSensorValue_diff': [ACU2_LongAccSensorValue_diff],
                'ACU2_LatAccSensorValue_diff': [ACU2_LatAccSensorValue_diff],
                'ACU2_VehicleDynYawRate_diff': [ACU2_VehicleDynYawRate_diff],
                'IDB1_BrakePedalApplied': [IDB1_BrakePedalApplied],
                'EPS1_SteerAngleSpd': [EPS1_SteerAngleSpd],
                'lane_curve': [lane_curve],
                'hour': [hour]
                }
        df = pd.DataFrame(data)
    return df
def convert_to_binary_with_length(number, desired_length):
    # 转成二进制
    binary_representation = bin(number)[2:]

    # 在二进制字符串前面补零，使其总长度为设定的长度
    binary_representation = binary_representation.zfill(desired_length)

    # 返回结果
    return binary_representation
def get_label_acc_active_100ms(df_100ms_save_path,pk_file_20ms, vechicle_id,daystr,hourstr, bagid,uuids,file_type):
    try:
        df_acc_100ms = pd.read_pickle(df_100ms_save_path)
        print(df_acc_100ms.columns)
    except Exception as e:
        print('data report read error, ', str(e))
    df_acc_100ms_list= df_acc_100ms[
        ['start_time_str','IDB1_BrakePedalApplied','IDB1_BrakePedalAppliedV','ADCS2_AEBPartialBrake','ADCS2_AEBFullBrake',
         'ADCS8_ACCState','path','ADCS12_longitudCtrlSysInfo','ADCS12_longitudDisableInfo',
         'ICU2_Odometer','IDB3_VehicleSpd','ACU2_LongAccSensorValue','ACU2_LatAccSensorValue','ACU2_VehicleDynYawRate','EPS1_SteerAngleSpd'
         ,'EPS1_TorsionBarTorque','CS1_GearPositionReqSt','nsecs']].values.tolist()

    dict_list = []
    #获取触发时刻状态：
    scid_dict=get_scid_time(df_acc_100ms)
    # 初始化上一行的数据为列表的第一个元素
    ADCS12_longitudCtrlSysInfo_last = df_acc_100ms_list[0][7]
    ADCS12_longitudDisableInfo_last= df_acc_100ms_list[0][8]
    for row in df_acc_100ms_list:
        start_time_str=row[0]
        IDB1_BrakePedalApplied = row[1]
        IDB1_BrakePedalAppliedV = row[2]
        ADCS2_AEBPartialBrake = row[3]
        ADCS2_AEBFullBrake = row[4]
        ADCS8_ACCState = row[5]
        path = row[6]
        ADCS12_longitudCtrlSysInfo= row[7]
        ADCS12_longitudDisableInfo= row[8]
        ICU2_Odometer = row[9]
        IDB3_VehicleSpd = row[10]
        ACU2_LongAccSensorValue = row[11]
        ACU2_LatAccSensorValue = row[12]
        ACU2_VehicleDynYawRate = row[13]
        EPS1_SteerAngleSpd = row[14]
        EPS1_TorsionBarTorque = row[15]
        CS1_GearPositionReqSt = row[16]
        nsecs = row[17]

        if ADCS12_longitudCtrlSysInfo == 1 and ADCS12_longitudCtrlSysInfo_last!=1:
            dict = {}
            dict["vehicle_id"] = vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1 = "ACC激活"
            level2 = "ACC激活成功"
            level3 = ""
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
            uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid


            add_to_bytehouse(dict)
            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            timestamp = get_timestamp(start_time_str)
            input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
            label_bucket_name = "bigdatatest"
            labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
            uploadjson(label_bucket_name, labe_object_key, json_string)




        if ADCS12_longitudDisableInfo!=0 and ADCS12_longitudDisableInfo_last==0:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = ""
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



            logging.info("激活失败原因判断。。。。")
            get_label_acc_active_20ms(pk_file_20ms, vechicle_id, daystr, hourstr, bagid, uuids, file_type,nsecs,start_time_str,ICU2_Odometer,IDB3_VehicleSpd,ACU2_LongAccSensorValue,ACU2_LatAccSensorValue,ACU2_VehicleDynYawRate,EPS1_SteerAngleSpd,EPS1_TorsionBarTorque,CS1_GearPositionReqSt)




        if ADCS12_longitudCtrlSysInfo==2:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：刹车踏板踩下"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudCtrlSysInfo==3:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：主驾安全带处于未系紧状态"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudCtrlSysInfo==4 or ADCS12_longitudCtrlSysInfo==5 or ADCS12_longitudCtrlSysInfo==6:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：四门两盖任一处于开启状态"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudCtrlSysInfo==7:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：EPB拉起"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudCtrlSysInfo==8:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：底盘(预留)"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)


        if ADCS12_longitudCtrlSysInfo!=0 and (ADCS2_AEBPartialBrake==1 or ADCS2_AEBFullBrake==1):
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：AEB介入"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudDisableInfo!=0 and ADCS8_ACCState==6:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：系统故障"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)


        if ADCS12_longitudDisableInfo==1:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：速度不满足"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudDisableInfo==10:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：开关未开"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudDisableInfo==11:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：竞速模式"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)



        if ADCS12_longitudDisableInfo==11:
            dict = {}
            dict["vehicle_id"]=vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1="ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：竞速模式"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["scid_start_time_str"] = scid_dict["scid_start_time_str"]
            dict["icu2_odometer"] = scid_dict["ICU2_Odometer"]
            dict["idb3_vehiclespd"] = scid_dict["IDB3_VehicleSpd"]
            dict["acu2_longaccsensorvalue"] = scid_dict["ACU2_LongAccSensorValue"]
            dict["acu2_lataccsensorvalue"] = scid_dict["ACU2_LatAccSensorValue"]
            dict["acu2_vehicledynyawrate"] = scid_dict["ACU2_VehicleDynYawRate"]
            dict["eps1_steeranglespd"] = scid_dict["EPS1_SteerAngleSpd"]
            dict["eps1_torsionbartorque"] = scid_dict["EPS1_TorsionBarTorque"]
            dict["cs1_gearpositionreqst"] = scid_dict["CS1_GearPositionReqSt"]

            uid_string=vechicle_id+start_time_str+bagid+level1+level2+level3
            uid=str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp=get_timestamp(start_time_str)
            input_string=vechicle_id+bagid+timestamp+uuids+file_type+level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string))+".json"
            label_bucket_name="bigdatatest"
            labe_object_key="EP40/TDA4/LABEL/"+daystr+"/"+hourstr+"/"+vechicle_id+"/"+filename
            uploadjson(label_bucket_name, labe_object_key, json_string)


        ADCS12_longitudCtrlSysInfo_last = ADCS12_longitudCtrlSysInfo
        ADCS12_longitudDisableInfo_last=ADCS12_longitudDisableInfo
def get_binary_with(SuppressReason):
    # 设定希望的二进制长度
    desired_length = 27
    # 获取二进制表示的位数
    num_bits = SuppressReason.bit_length()
    # 动态调整长度并获取二进制表示
    binary_representation = convert_to_binary_with_length(SuppressReason, max(num_bits, desired_length))
    return binary_representation
def get_label_acc_active_20ms(df_100ms_save_path, vechicle_id, daystr, hourstr, bagid, uuids, file_type,nsecs,start_time_str,ICU2_Odometer,IDB3_VehicleSpd,ACU2_LongAccSensorValue,ACU2_LatAccSensorValue,ACU2_VehicleDynYawRate,EPS1_SteerAngleSpd,EPS1_TorsionBarTorque,CS1_GearPositionReqSt):
    try:
        df_acc_20ms = pd.read_pickle(df_100ms_save_path)
        print(df_acc_20ms.columns)
    except Exception as e:
        print('data report read error, ', str(e))

    df_acc_20ms_list= df_acc_20ms[
        ['start_time_str','path','nsecs','SuppressReason']].values.tolist()

    list_data=get_can_out_20ms_list(df_acc_20ms_list, nsecs)
    path = list_data[1]
    nsecs = list_data[2]
    SuppressReason = list_data[3]
    logging.info("nsecs: "+ str(nsecs))
    binary_representation = get_binary_with(SuppressReason)
    # 根据每个位的值设置相应的变量
    Bite0 = int(binary_representation[-1])
    Bite1 = int(binary_representation[-2])
    Bite2 = int(binary_representation[-3])
    Bite3 = int(binary_representation[-4])
    Bite4 = int(binary_representation[-5])
    Bite5 = int(binary_representation[-6])
    Bite6 = int(binary_representation[-7])
    Bite7 = int(binary_representation[-8])
    Bite8 = int(binary_representation[-9])
    Bite9 = int(binary_representation[-10])
    Bite10 = int(binary_representation[-11])
    Bite11 = int(binary_representation[-12])
    Bite12 = int(binary_representation[-13])
    Bite13 = int(binary_representation[-14])
    Bite14 = int(binary_representation[-15])
    Bite15 = int(binary_representation[-16])
    Bite16 = int(binary_representation[-17])
    Bite17 = int(binary_representation[-18])
    Bite18 = int(binary_representation[-19])
    Bite19 = int(binary_representation[-20])
    Bite20 = int(binary_representation[-21])
    Bite21 = int(binary_representation[-22])
    Bite22 = int(binary_representation[-23])
    Bite23 = int(binary_representation[-24])
    Bite24 = int(binary_representation[-25])
    Bite25 = int(binary_representation[-26])
    Bite26 = int(binary_representation[-27])

    if Bite0:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：ACCreset"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)
    if Bite1:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：诊断出故障"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)
    if Bite2:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：无目标时车速低于 15"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)
    if Bite3:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：ABS,ESC,TCS,ARP 激活"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)
    if Bite4:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：解安全带"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite5:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：车速过高"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite6:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：曲率过大"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite7:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：加速度过大"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite8:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：四门两盖"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite9:
        binary_value = bin(SuppressReason)[2:]

        if str(binary_value) == "1000000000" or str(binary_value) == "1000000100":
            dict = {}
            dict["vehicle_id"] = vechicle_id
            dict["start_time_str"] = start_time_str
            dict["scid"] = bagid
            dict["path"] = path
            level1 = "ACC激活"
            level2 = "ACC激活失败"
            level3 = "原因：踩制动"
            dict["level1"] = level1
            dict["level2"] = level2
            dict["level3"] = level3
            day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
            month = start_time_str[0:4] + start_time_str[5:7]
            dict["day"] = day
            dict["month"] = month
            dict["icu2_odometer"] = ICU2_Odometer
            dict["idb3_vehiclespd"] = IDB3_VehicleSpd
            dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
            dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
            dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
            dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
            dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
            dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

            uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
            uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
            dict["uid"] = uid

            json_string = json.dumps(dict, ensure_ascii=False, indent=None)
            add_to_bytehouse(dict)

            timestamp = get_timestamp(start_time_str)
            input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
            filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
            label_bucket_name = "bigdatatest"
            labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
            uploadjson(label_bucket_name, labe_object_key, json_string)
    if Bite10:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：VCU ACC not ready"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite11:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：ACC not enable IDB5_ACC _Enable"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite12:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：EPB not allow"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite13:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：Act gear 不在驱动档或无效"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite14:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：后溜"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)
    if Bite15:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：AEB 或相关激活"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite16:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：IDB7_DynParkBrkByIDBActive"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite17:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：HDC 激活，TCS 不可用"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite18:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：泊车系统"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite19:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：ACC_ReqLim==0x03 或制动盘过热或 ABS EBD ESC TCS fail"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite20:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：油门无效或 standstill 无效"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite21:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：横向加速度纵向加速度 yawrate 无效"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite22:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：车轮方向无效"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite23:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：转向角信号无效"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite24:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：故障诊断的抑制信号"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite25:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：融合目标时间戳不变导致故障"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)

    if Bite26:
        dict = {}
        dict["vehicle_id"] = vechicle_id
        dict["start_time_str"] = start_time_str
        dict["scid"] = bagid
        dict["path"] = path
        level1 = "ACC激活"
        level2 = "ACC激活失败"
        level3 = "原因：融合线时间戳不变导致故障"
        dict["level1"] = level1
        dict["level2"] = level2
        dict["level3"] = level3
        day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
        month = start_time_str[0:4] + start_time_str[5:7]
        dict["day"] = day
        dict["month"] = month
        dict["icu2_odometer"] = ICU2_Odometer
        dict["idb3_vehiclespd"] = IDB3_VehicleSpd
        dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
        dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
        dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
        dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
        dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
        dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

        uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
        dict["uid"] = uid

        json_string = json.dumps(dict, ensure_ascii=False, indent=None)
        add_to_bytehouse(dict)

        timestamp = get_timestamp(start_time_str)
        input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
        filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
        label_bucket_name = "bigdatatest"
        labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
        uploadjson(label_bucket_name, labe_object_key, json_string)
def get_model_acc_active_100ms(df_100ms_save_path, vechicle_id,daystr,hourstr, bagid,uuids,file_type, dtc,sc):
    try:
        df_acc_100ms = pd.read_pickle(df_100ms_save_path)
        print(df_acc_100ms.columns)
    except Exception as e:
        print('data report read error, ', str(e))
    df_acc_100ms_list= df_acc_100ms[
        ['start_time_str','path','nsecs','VLCCDHypotheses_Hypothesis_0_fTTC','VLCCDHypotheses_Hypothesis_0_fDistX','VLCCDHypotheses_Hypothesis_0_fDistY',
         'VLCCDHypotheses_Hypothesis_0_fVrelX','VLCCDHypotheses_Hypothesis_0_fVrelY','IDB3_VehicleSpd','ACU2_LongAccSensorValue','ACU2_LatAccSensorValue',
         'ACU2_VehicleDynYawRate','IDB1_BrakePedalApplied','EPS1_SteerAngleSpd','CamLaneData_CourseInfo_1_CourseInfoSegNear_f_C0',
         'ADCS12_longitudCtrlSysInfo','ADCS12_longitudDisableInfo','ICU2_Odometer','EPS1_TorsionBarTorque','CS1_GearPositionReqSt'
         ]].values.tolist()


    found_index = -9999
    start_time_str=""
    found_ICU2_Odometer=0.0
    found_IDB3_VehicleSpd=0.0
    found_ACU2_LongAccSensorValue=0.0
    found_ACU2_LatAccSensorValue=0.0
    found_ACU2_VehicleDynYawRate=0.0
    found_EPS1_SteerAngleSpd=0.0
    found_EPS1_TorsionBarTorque=0.0
    found_CS1_GearPositionReqSt=0
    # 遍历列表
    for index, element in enumerate(df_acc_100ms_list):
        start_time_str=element[0]
        path = element[1]
        nsecs = element[2]
        ADCS12_longitudCtrlSysInfo = element[15]
        ADCS12_longitudDisableInfo = element[16]
        ICU2_Odometer= element[17]
        IDB3_VehicleSpd=element[8]
        ACU2_LongAccSensorValue = element[9]
        ACU2_LatAccSensorValue=element[10]
        ACU2_VehicleDynYawRate=element[11]
        EPS1_SteerAngleSpd=element[13]
        EPS1_TorsionBarTorque = element[18]
        CS1_GearPositionReqSt = element[19]
        if ADCS12_longitudCtrlSysInfo==1 or ADCS12_longitudDisableInfo!= 0:
            found_index = index
            found_ICU2_Odometer=ICU2_Odometer
            found_IDB3_VehicleSpd=IDB3_VehicleSpd
            found_ACU2_LongAccSensorValue=ACU2_LongAccSensorValue
            found_ACU2_LatAccSensorValue=ACU2_LatAccSensorValue
            found_ACU2_VehicleDynYawRate=ACU2_VehicleDynYawRate
            found_EPS1_SteerAngleSpd=EPS1_SteerAngleSpd
            found_EPS1_TorsionBarTorque=EPS1_TorsionBarTorque
            found_CS1_GearPositionReqSt=CS1_GearPositionReqSt


            break  # 找到第一个符合条件的元素就跳出循环
    logging.info("found_index: "+str(found_index))
    df=get_model_feature(found_index, df_acc_100ms_list, start_time_str)

    df_std = sc.transform(df)
    y_pred = dtc.predict(df_std)
    logging.info("预测结果： "+str(y_pred))
    #输出值为2代表已碰撞，1代表危险但未碰撞，0代表不危险
    if y_pred[0]==2:
        level1 = "已碰撞"
    elif y_pred[0]==1:
        level1 = "危险但未碰撞"
    elif y_pred[0]== 0:
        level1 = "不危险"
    dict = {}
    dict["vehicle_id"] = vechicle_id
    dict["start_time_str"] = start_time_str
    dict["scid"] = bagid
    dict["path"] = path
    level2 = ""
    level3 = ""
    dict["level1"] = level1
    dict["level2"] = level2
    dict["level3"] = level3
    day = start_time_str[0:4] + start_time_str[5:7] + start_time_str[8:10]
    month = start_time_str[0:4] + start_time_str[5:7]
    dict["day"] = day
    dict["month"] = month
    dict["scid_start_time_str"] =start_time_str
    dict["icu2_odometer"] = ICU2_Odometer
    dict["idb3_vehiclespd"] = IDB3_VehicleSpd
    dict["acu2_longaccsensorvalue"] = ACU2_LongAccSensorValue
    dict["acu2_lataccsensorvalue"] = ACU2_LatAccSensorValue
    dict["acu2_vehicledynyawrate"] = ACU2_VehicleDynYawRate
    dict["eps1_steeranglespd"] = EPS1_SteerAngleSpd
    dict["eps1_torsionbartorque"] = EPS1_TorsionBarTorque
    dict["cs1_gearpositionreqst"] = CS1_GearPositionReqSt

    uid_string = vechicle_id + start_time_str + bagid + level1 + level2 + level3
    uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, uid_string))
    dict["uid"] = uid

    json_string = json.dumps(dict, ensure_ascii=False, indent=None)
    add_to_bytehouse(dict)

    timestamp = get_timestamp(start_time_str)
    input_string = vechicle_id + bagid + timestamp + uuids + file_type + level3
    filename = str(uuid.uuid3(uuid.NAMESPACE_DNS, input_string)) + ".json"
    label_bucket_name = "bigdatatest"
    labe_object_key = "EP40/TDA4/LABEL/" + daystr + "/" + hourstr + "/" + vechicle_id + "/" + filename
    uploadjson(label_bucket_name, labe_object_key, json_string)
